package com.zg.scf.domain.req.product;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zg.common.core.req.AddReq;
import com.zg.common.core.req.EditReq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * DESCRIPTION
 *
 * @author zhanfeng.liang
 * @since 2025-07-22
 */
@Data
@ApiModel(value = "CreditEditReq", description = "授信信息数据传输对象，用于接收前端表单数据")
public class CreditEditReq extends EditReq {
    @ApiModelProperty(value = "授信类型", example = "产品授信", required = true)
    @NotEmpty(message = "授信类型不能为空")
    @Length(max = 20, message = "授信类型长度不能超过20")
    private String creditType;

    @ApiModelProperty(value = "授信编号", example = "CRED_20250725_001", required = true)
    @NotEmpty(message = "授信编号不能为空")
    @Length(max = 50, message = "授信编号长度不能超过50")
    private String creditCode;

    @ApiModelProperty(value = "金融机构", example = "XX银行", required = true)
    @NotNull(message = "金融机构不能为空")
    private Long bankId;

    @ApiModelProperty(value = "授信名称", example = "企业经营贷授信", required = true)
    @NotEmpty(message = "授信名称不能为空")
    @Length(max = 200, message = "授信名称长度不能超过200")
    private String creditName;

    @ApiModelProperty(value = "产品类型", example = "经营贷", required = true)
    @NotNull(message = "产品类型不能为空")
    private Long productTypeId;

    @ApiModelProperty(value = "授信流程", example = "初审->复审->终审", required = true)
    @NotEmpty(message = "授信流程不能为空")
    @Length(max = 200, message = "授信流程长度不能超过200")
    private String creditProcess;

    @ApiModelProperty(value = "授信期限单位", example = "年", required = true)
    @NotEmpty(message = "授信期限单位不能为空")
    @Length(max = 20, message = "授信期限单位长度不能超过20")
    private String termUnit;

    @ApiModelProperty(value = "授信时限开始年份", example = "2025", required = true)
    @NotNull(message = "授信时限开始年份不能为空")
    @Min(value = 2000, message = "授信时限开始年份不能小于2000")
    @Max(value = 2050, message = "授信时限开始年份不能大于2050")
    private Integer periodBegin;

    @ApiModelProperty(value = "授信时限结束年份", example = "2030", required = true)
    @NotNull(message = "授信时限结束年份不能为空")
    @Min(value = 2000, message = "授信时限结束年份不能小于2000")
    @Max(value = 2050, message = "授信时限结束年份不能大于2050")
    private Integer periodEnd;

    @ApiModelProperty(value = "授信审批时间", example = "2025-07-25", required = true,
            notes = "日期格式：yyyy-MM-dd")
    @NotNull(message = "授信审批时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date approvalDate;

    @ApiModelProperty(value = "授信额度下限（万元）", example = "50.00", required = true)
    @NotNull(message = "授信额度下限不能为空")
    @DecimalMin(value = "0.0", message = "授信额度下限不能小于0")
    private BigDecimal amountLow;

    @ApiModelProperty(value = "授信额度上限（万元）", example = "500.00", required = true)
    @NotNull(message = "授信额度上限不能为空")
    @DecimalMin(value = "0.0", message = "授信额度上限不能小于0")
    @DecimalMax(value = "100000.0", message = "授信额度上限不能超过100000万元")
    private BigDecimal amountHigh;

    @ApiModelProperty(value = "企业存续时间要求（年以上）", example = "3")
    @Min(value = 0, message = "企业存续时间不能为负数")
    private Integer companyContinueYears;

    @ApiModelProperty(value = "企查查分", example = "AA")
    @Length(max = 200, message = "企查查分长度不能超过200")
    private String companyScore;


    @ApiModelProperty(value = "企业类型", example = "国有,民营")
    @Length(max = 200, message = "企业类型长度不能超过200")
    private String companyType;

    @ApiModelProperty(value = "国标行业", example = "制造业,服务业")
    @Length(max = 200, message = "国标行业长度不能超过200")
    private String industry;

    @ApiModelProperty(value = "严重违法限制年数", example = "1")
    @Min(value = 0, message = "严重违法限制年数不能为负数")
    private Integer seriousViolationYears;

    @ApiModelProperty(value = "严重违法次数", example = "0")
    @Min(value = 0, message = "严重违法次数不能为负数")
    private Integer seriousViolationTimes;

    @ApiModelProperty(value = "实缴资本要求（万元以上）", example = "100.00")
    @DecimalMin(value = "0.0", message = "实缴资本不能为负数")
    private BigDecimal paidInCapital;

    @ApiModelProperty(value = "注册资本要求（万元以上）", example = "200.00")
    @DecimalMin(value = "0.0", message = "注册资本不能为负数")
    private BigDecimal registeredCapital;

    @ApiModelProperty(value = "人员规模要求（人以上）", example = "50")
    @Min(value = 0, message = "人员规模不能为负数")
    private Integer staffScale;

    // 纳税信用相关字段
    @ApiModelProperty(value = "纳税信用等级（A、B、C、D、M等）", example = "A")
    private String taxCredit;

    @ApiModelProperty(value = "国有土地受让次数以下", example = "3")
    private Integer stateLandTransfer;

    @ApiModelProperty(value = "抽查问题次数以下", example = "0")
    private Integer samplingProblem;

    @ApiModelProperty(value = "供应商数量（个以上）", example = "50")
    private Integer supplierCount;

    @ApiModelProperty(value = "客户数量（个以上）", example = "100")
    private Integer customerCount;

    @ApiModelProperty(value = "产权交易次数以下", example = "2")
    private Integer propertyRightTransaction;

    @ApiModelProperty(value = "资产拍卖次数以下", example = "0")
    private Integer assetAuction;

    // 经营风险相关字段
    @ApiModelProperty(value = "行政处罚次数以下", example = "0")
    private Integer administrativePenalty;

    @ApiModelProperty(value = "环保处罚次数以下", example = "0")
    private Integer environmentalPenalty;

    @ApiModelProperty(value = "公示催告次数以下", example = "1")
    private Integer publicWarning;

    // 法律风险相关字段
    @ApiModelProperty(value = "司法拍卖次数以下", example = "0")
    private Integer judicialAuction;

    @ApiModelProperty(value = "司法案件次数以下", example = "2")
    private Integer judicialCase;

    @ApiModelProperty(value = "被告立案次数以下", example = "1")
    private Integer defendantCase;

    @ApiModelProperty(value = "开庭公告次数以下", example = "1")
    private Integer courtNotice;

    // 知识能力相关字段
    @ApiModelProperty(value = "专利信息数量（个以上）", example = "10")
    private Integer patentInfo;

    @ApiModelProperty(value = "软件著作数量（个以上）", example = "5")
    private Integer softwareCopyright;

    // 财务情况相关字段
    @ApiModelProperty(value = "流动比例最小值（%）", example = "120.50")
    private BigDecimal currentRatioMin;

    @ApiModelProperty(value = "流动比例最大值（%）", example = "150.80")
    private BigDecimal currentRatioMax;

    @ApiModelProperty(value = "速动比例最小值（%）", example = "80.20")
    private BigDecimal quickRatioMin;

    @ApiModelProperty(value = "速动比例最大值（%）", example = "100.50")
    private BigDecimal quickRatioMax;

    @ApiModelProperty(value = "资产负债率最小值（%）", example = "30.00")
    private BigDecimal assetLiabilityRatioMin;

    @ApiModelProperty(value = "资产负债率最大值（%）", example = "50.00")
    private BigDecimal assetLiabilityRatioMax;

    @ApiModelProperty(value = "产权比率最小值（%）", example = "40.00")
    private BigDecimal equityRatioMin;

    @ApiModelProperty(value = "产权比率最大值（%）", example = "60.00")
    private BigDecimal equityRatioMax;

    @ApiModelProperty(value = "加权净资产负债率最小值（%）", example = "20.00")
    private BigDecimal debtToEquityRatioMin;

    @ApiModelProperty(value = "加权净资产负债率最大值（%）", example = "30.00")
    private BigDecimal debtToEquityRatioMax;

    @ApiModelProperty(value = "毛利率最小值（%）", example = "25.00")
    private BigDecimal grossProfitMarginMin;

    @ApiModelProperty(value = "毛利率最大值（%）", example = "35.00")
    private BigDecimal grossProfitMarginMax;

    @ApiModelProperty(value = "净利率最小值（%）", example = "10.00")
    private BigDecimal netProfitMarginMin;

    @ApiModelProperty(value = "净利率最大值（%）", example = "15.00")
    private BigDecimal netProfitMarginMax;


    private String state;
}
